﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Staff_Mark : System.Web.UI.Page
{
    string mamon = "";
    string manhom = "";
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        mamon = DropDownList1.SelectedValue;
        manhom = DropDownList2.SelectedValue;

        if (mamon == "-1" || manhom == "-1")
        {
            Label1.Visible = true;
            Label3.Visible = false; return;
        }

        string mahocphan = mamon + "." + manhom;
        List<HocPhan> ds = new List<HocPhan>();

        if (manhom == "10")
            ds.AddRange(new DanhsachHocPhan().danhsach10);
        else
            ds.AddRange(new DanhsachHocPhan().danhsach11);

        HocPhan hocphan = null;
        foreach (HocPhan item in ds)
        {
            if (item.mahp == mahocphan)
            {
                hocphan = item;
                break;
            }
        }

        if (hocphan != null)
        {
            Label1.Visible = false;
            Label3.Visible = true;
            Label3.Text = hocphan.mahp + "  " + hocphan.tenhp;
        }

        GridView1.DataSource = new DanhsachHocPhan().dsCD;
        GridView1.DataBind();
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandSource == "Edit_Mark")
        {
            string maSv = e.CommandArgument.ToString();
            List<StudentMark> ds = new DanhsachHocPhan().dsCD;
            int id = -1;
            for (int i = 0; i < ds.Count; i++)
            {
                if (ds.ElementAt(i).maSv == maSv)
                {
                    id = i;
                    break;
                }
            }

            if (id != -1)
            {
                GridView1.EditIndex = id;
                GridView1.Rows[id].RowState = DataControlRowState.Edit;
            }
        }
        else if (e.CommandSource == "Save_Mark")
        {
        }
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        GridView1.DataBind();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

    }
}